﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace DetergentTest
{
    public static class TestHelper
    {
        public static void Throws<T>(Action act) where T : Exception
        {
            var errorThrown = false;
            try
            {
                act();
            }
            catch (T ex)
            {
                errorThrown = true;
            }
            catch (Exception badEx)
            {
                Assert.Fail("Wrong exception thrown");
            }
            finally
            {
                if (!errorThrown)
                {
                    Assert.Fail("Exception was not thrown");
                }
            }
        }
    }
}
